package org.csmzxy.class2334;

class Shape{
    private String type;
    private String color;
    public Shape(String type,String color){
        this.type = type;
        this.color = color;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj){
            return true;
        }
        if(obj == null || !(obj instanceof Shape)){
            return false;
        }
        Shape shape =(Shape) obj;
        return type.equals(shape.type) && color.equals(shape.color);
    }
    @Override
    public String toString(){
        return "Shape{" + "type'" + ",color='" + color + '}';
    }
}
public class Example01 {
    public static void main(String[] args){
        Shape shape1 = new Shape("Circle","Red");
        Shape shape2 = new Shape("Circle","Red");
        System.out.println("两个形状是否相等：" + shape1.equals(shape2));
        System.out.println(shape1);
        System.out.println(shape2);
    }
}
